package com.gupao.zigong.prototype;

import com.alibaba.fastjson.JSON;

/**
 * @author zigong
 * @description JSON 序列化工具
 * @date 2020/9/17 20:37
 */
public class JSONSerializer<T> implements ISerializer<T> {
    @Override
    public byte[] serialize(T t) {
        return JSON.toJSONBytes(t);
    }

    @Override
    public T deserialize(byte[] bytes, Class<? extends T> clazz) {
        return (T) JSON.parseObject(bytes, clazz);
    }
}
